using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Net;
using System.IO;

namespace Evolus.Mercury.Web.Controllers
{
    public class ProxyController : Controller
    {
        //
        // GET: /Proxy/

        public ActionResult Index(string url)
        {
            ViewData["URL"] = url;
            ViewData["HTML"] = GetHtml(url);
            return View();
        }

        private string GetHtml(string url)
        {
            HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
            request.Method = "GET";
            request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)";
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            Stream stream = response.GetResponseStream();
            StreamReader sr = new StreamReader(stream);
            string result = sr.ReadToEnd();
            sr.Close();
            response.Close();
            return result;
        }
    }
}
